export default {
	props: {
		label: {
			type: String,
			default: '',
		},
		prop: {
			type: String,
			default: '',
		},
		type: {
			type: String,
			default: '',
		},
		sortable: {
			type: Boolean,
			default: false,
		},
		filterable: {
			type: Boolean,
			default: false,
		},
	},
	render: function(h) {
		let defaultValue = '';
		const selfData = this.$options._parentVnode.data.selfData || {};
		const selfIndex = this.$options._parentVnode.data.selfIndex;
		if (Object.keys(selfData).length > 0) {
			if (this.prop) {
				this.prop.split('.').forEach(k => {
					defaultValue = defaultValue === '' ? selfData[k] : defaultValue[k];
				});
				defaultValue = [undefined, null].includes(defaultValue) ? '　' : defaultValue;
			}
		}
		if (this.type === 'index') {
			return h(
				'div',
				{
					attrs: {
						class: 'virtual-table-td',
					},
				},
				selfIndex + 1
			);
		} else if (this.type === 'selection') {
			return h(
				'div',
				{
					attrs: {
						class: 'virtual-table-td',
					},
				},
				[
					h(
						'i',
						{
							style: { cursor: 'pointer' },
							attrs: { class: '' },
						},
						''
					),
				]
			);
		} else {
			return h(
				'div',
				{
					attrs: {
						class: 'virtual-table-td',
					},
				},
				[
					this._t('default', [this._v(defaultValue)], {
						row: selfData,
						index: selfIndex,
					}),
				],
				2
			);
		}
	},
};
